<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" 
    "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml"
	xmlns:ui="http://java.sun.com/jsf/facelets"
	xmlns:h="http://java.sun.com/jsf/html"
	xmlns:f="http://java.sun.com/jsf/core"
	xmlns:p="http://primefaces.org/ui">

<ui:composition template="/webApp/layout/template.xhtml">
	<ui:define name="conteudo">
		<h:panelGrid>
			<h:form prependId="false">
				<p:growl id="messages" autoUpdate="true"></p:growl>
				<h:panelGrid columns="2">
					<p:outputLabel value="Nome:" />
					<p:inputText value="#{clienteBean.nome}" id="nome" />

					<p:outputLabel value="Tipo Pessoa:" />
					<p:selectOneMenu value="#{clienteBean.tipoPessoa}"  id="tipo">
						<f:selectItem itemValue="Fisica" itemLabel="Fisica" />
						<f:selectItem itemValue="Juridica" itemLabel="Juridica" />
					</p:selectOneMenu>
				</h:panelGrid>
				
				<h:panelGrid id="painel" columns="2" rendered="#{clienteBean.listaCliente != null}">
						<p:dataTable value="#{clienteBean.listaCliente}" var="cli">
							<p:column>
								<f:facet name="header">
									<p:outputLabel value="Código"/>
								</f:facet>
								<p:outputLabel value="#{cli.codigo}"/>
							</p:column>
							
							<p:column>
								<f:facet name="header">
									<p:outputLabel value="Telefone"/>
								</f:facet>
									<p:outputLabel value="#{cli.telefoneFixo}"/>
							</p:column>
							
							<p:column>
								<f:facet name="header">
									<p:outputLabel value="Celular"/>
								</f:facet>
								<p:outputLabel value="#{cli.telefoneCelular}"/>
							</p:column>
							
							<p:column>
								<f:facet name="header">
									<p:outputLabel value="Tipo"/>
								</f:facet>
								<p:outputLabel value="#{cli.tipoPessoa}"/>
							</p:column>
							
							<p:column>
								<f:facet name="header">
									<p:outputLabel value="Editar"/>
								</f:facet>
								<h:commandLink action="#{clienteBean.editarUsuario}">
									<h:graphicImage library="images" name="editar.gif" title="Editar Usuário" />
									<f:param name="codigo" value="#{cli.codigo}" />
									<f:param name="tipoPessoa" value="#{cli.tipoPessoa}" />		
								</h:commandLink>
								
								<h:commandLink action="#{pedidoBean.listaPedidos}">
										<f:param name="codigo" value="#{cli.codigo}" />
									    <h:graphicImage library="images" name="pedidoIcone.png" 
									    title="Ver Pedidos do Cliente"/>
								</h:commandLink>
							</p:column>
					</p:dataTable>
				</h:panelGrid>
					
				<h:panelGrid columns="2" >	
					<h:commandButton value="Consultar"  actionListener="#{clienteBean.buscarClientes}"/>
				</h:panelGrid>
			</h:form>
		</h:panelGrid>
	</ui:define>
</ui:composition>
</html>